/******************************************************************************
 * Epigraph compiler                                                          *
 * Copyright © 2011 Grigorev Svyatoslav                                       *
 *                                                                            *
 * This program is free software: you can redistribute it and/or modify       *
 *     it under the terms of the GNU General Public License as published by   *
 *     the Free Software Foundation, either version 3 of the License, or      *
 *     (at your option) any later version.                                    *
 *                                                                            *
 *     This program is distributed in the hope that it will be useful,        *
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of         *
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
 *     GNU General Public License for more details.                           *
 *                                                                            *
 *     You should have received a copy of the GNU General Public License      *
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
 ******************************************************************************/

package epg;

import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;

/**
 * @author: Grigorev Svyatoslav
 * Date: epg 2011-08-27 10:24
 */

public class WriteToFile {
	String filename;
	PrintWriter writer;

	WriteToFile(String _filename) {
		filename = _filename;
		writer = null;
		try {
			writer = new PrintWriter(
				new OutputStreamWriter(
					new FileOutputStream(filename), "windows-1251"));
		} catch (Exception ex) {
		}
	}

	protected void finalize() {
		writer.close();
	}

	public void print(String strPage) {
		if (writer != null)
			writer.write(strPage);
	}

	public void println(String strPage) {
		if (writer != null)
			writer.write(strPage + "\n");
	}

	public void close() {
		if (writer != null)
			writer.close();
	}

	public void print(int a) {
		print(Integer.toString(a));
	}

	public void println(int a) {
		println(Integer.toString(a));
	}

}